package com.duan.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.duan.dao.Daq_dbmsDao;
import com.duan.model.Datainfo;
import com.duan.model.Datasource;

public class TestWebTableJsonServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		//response.setCharacterEncoding("utf-8");
		JSONObject datagridData = new JSONObject();
		JSONArray row = new JSONArray();
		JSONObject rowkid = new JSONObject();
		
		rowkid.element("productid","FI-SW-01");
		rowkid.element("productname","Koi");
		rowkid.element("unitcost","10.00");
		rowkid.element("status","P");
		rowkid.element("listprice","36.50");
		rowkid.element("attr1","Large");
		rowkid.element("itemid","EST-1");
		row.add(rowkid);
		rowkid.element("productid","FI-SW-01");
		rowkid.element("productname","Koi");
		rowkid.element("unitcost","10.00");
		rowkid.element("status","P");
		rowkid.element("listprice","36.50");
		rowkid.element("attr1","Large");
		rowkid.element("itemid","EST-1");
		row.add(rowkid);
		
		datagridData.element("total",2);
		datagridData.element("rows",row);
		
		System.out.println(datagridData);
		PrintWriter out = response.getWriter();
		out.println(datagridData);
	}
}
